import request from '@/utils/request'

// 根据调拨单号查询调拨单信息
export function getTransferByCode(transferCode) {
  return request({
    url: '/mobile/wm/transfer/getByCode',
    method: 'get',
    params: { transferCode }
  })
}

export function getTransferById(transferId) {
  return request({
    url: '/mobile/wm/transfer/getById',
    method: 'get',
    params: { transferId }
  })
}

// 根据产品SN查询调拨单信息 未用
export function getTransferBySn(snCode) {
  return request({
    url: '/mobile/wm/transfer/getBySn',
    method: 'get',
    params: { snCode }
  })
}

// 根据调拨单行id查询行信息以及明细信息
export function getDetail(transferLineId) {
  return request({
    url: '/mobile/wm/transfer/getDetail',
    method: 'get',
    params: { transferLineId }
  })
}

// 新增转移调拨单明细
export function addTransferdetail(data) {
  return request({
    url: '/mes/wm/transferdetail',
    method: 'post',
    data: data
  })
}

// 修改转移调拨单明细
export function updateTransferdetail(data) {
  return request({
    url: '/mes/wm/transferdetail',
    method: 'put',
    data: data
  })
}

// 删除转移调拨单明细
export function delTransferdetail(detailId) {
  return request({
    url: '/mes/wm/transferdetail/' + detailId,
    method: 'delete'
  })
}

// 库存同步 
export function syncStock(transferId) {
  return request({
    url: '/mes/wm/transferdetail/syncStock/' + transferId,
    method: 'post'
  })
}

// 明细拣货确认
export function detailShipConfirm(detailId) {
  return request({
    url: '/mes/wm/transferdetail/shipConfirm/' + detailId,
    method: 'post'
  })
}

// 明细上架（也就是修改明细的仓库等数据，后台默认改状态为已上架，可以多次上架）
export function detailReceiveConfirm(data) {
  return request({
    url: '/mes/wm/transferdetail/receiveConfirm',
    method: 'post',
    data: data
  })
}

//------------单据状态操作--------------/
// 拣货确认
export function pickConfirm(transferId) {
  return request({
    url: '/mes/wm/transfer/pickConfirm/' + transferId,
    method: 'put'
  })
}

// 发货确认
export function shipConfirm(transferId) {
  return request({
    url: '/mes/wm/transfer/shipConfirm/' + transferId,
    method: 'put'
  })
}

// 收货确认
export function receiveConfirm(transferId) {
  return request({
    url: '/mes/wm/transfer/receiveConfirm/' + transferId,
    method: 'put'
  })
}

// 上架完成确认
export function shelfConfirm(transferId) {
  return request({
    url: '/mes/wm/transfer/shelfConfirm/' + transferId,
    method: 'put'
  })
}

// 系统入库完成（执行转移）
export function execute(transferId) {
  return request({
    url: '/mes/wm/transfer/execute/' + transferId,
    method: 'put'
  })
}